<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateAdminRoleTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('admin_role', function (Blueprint $table) {
            $table->increments('role_id');
            $table->string('role_name', 100)->unique()->comment('角色名');
            $table->mediumText('role_content')->nullable()->comment('工作内容或职责');
            $table->timestamps();
            $table->index('role_name');
        });

        \Illuminate\Support\Facades\DB::statement("ALTER TABLE admin_role AUTO_INCREMENT=100");

        $data = [
            ['role_name' => '管理员', 'role_content' => '后台的一些常用管理，如职位添加、用户管理、权限等'],
            ['role_name' => '老师', 'role_content' => '老师，教书育人']
        ];
        DB::table('admin_role')->insert($data);
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('admin_role');
    }
}
